<?php
include("include/textcenter.php"); 
include("include/db.php");
$ProductNo= $_GET["id"];
if(isset($_POST['submitupdate']))
{
   // $ProductImage = $_POST['ProductImage'];
        $file = $_FILES["ProductImage"];
		//$thum = $_FILES["Thumbnail"];
		$file_name = $file["name"];
		//$thum_name = $thum["name"];
		$file_ext = explode(".",$file_name);
	//	$thum_ext = explode(".",$thum_name);
		if($file["name"] == "")
		{	
            $ProductImage=$file_name;
            $sql = "update vnf_product_image set ProductImage='$ProductImage' 
            where ProductNo=".$ProductNo;
            mysql_query($sql);
	       echo '<meta http-equiv="Refresh" content="0;URL=product_image_list.php" />';
	      return;
        }
         else if(($file["name"] != "")&&($file_ext[count($file_ext)-1] == "jpg" || $file_ext[count($file_ext)-1] == "jpeg" || $file_ext[count($file_ext)-1] == "gif" || $file_ext[count($file_ext)-1] == "png"))
		{
            $ProductImage=$file_name;
            $sql = "update vnf_product_image set ProductImage='$ProductImage' 
            where ProductNo=".$ProductNo;
            mysql_query($sql);
            move_uploaded_file($_FILES["ProductImage"]["tmp_name"],"public/asset/".$_FILES["ProductImage"]["name"]);
           	echo '<meta http-equiv="Refresh" content="0;URL=product_image_list.php?id='.$ProductNo.'" />';
           	return;
        }
        else if(($file["name"] != "")&&($file_ext[count($file_ext)-1] != "jpg" || $file_ext[count($file_ext)-1] != "jpeg" || $file_ext[count($file_ext)-1] != "gif" || $file_ext[count($file_ext)-1] != "png"))
		{
			$alert='<script type="text/javascript">
			alert("Please choose file type jpg, jpeg, gif");
			</script>';
			echo $alert;
		}
        echo $sql;
    }
?>
<html>
<head>
<meta name="description" content="Admin<?php echo $tagdescription?>">
<meta name="keywords" content="<?php echo $tagkeywords?> Main">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title><?php echo $tagtitle?></title>

<script type="text/javascript" src="simpletreemenu.js">
/***********************************************
* Simple Tree Menu- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<link rel="stylesheet" type="text/css" href="simpletree.css" />
<LINK rel="StyleSheet" href="include/css_classes.css" type="text/css">

</head>



<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" link="#0000FF" vlink="#800080" alink="#FF0000" bgcolor="#FFFFFF">
<!-- -------------------Header---------------------------- -->
<?php include("include/header.php"); ?>
<!-- -------------------End Header---------------------------- -->


<div align="center">
<table border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="12%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="200" height="1"></td>
		<td width="1%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="16" height="1"></td>
		<td width="86%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="16" height="1"></td>
	</tr>	
	<tr>
		<!-- ///////////////////Begin Leftmenu/////////////////// -->
		<td width="12%" valign="top" bgcolor="#FFFFFF">
		<?php include("include/leftmenu.php"); ?>
		</td>
		<!-- ///////////////////End Leftmenu/////////////////// -->
		
		<td width="1%" valign="top" background="public/images/homepage/16.gif">&nbsp;</td>
		<td width="86%" valign="top">
	<br>
<!-- -------------------Begin Body---------------------------- --------------------------------------------------------->
<p class="title16B">&nbsp;Product - Update Image</p>
<div align="center">
 
<table border="0" width="960" cellspacing="0" cellpadding="0">
	<tr>
		<td>
		
		<form action="" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="ProductImage" id="file" /> 
<br />
<input type="submit" name="submitupdate" value="Submit" />
</form>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
</table>
 
</div>


<!-- -------------------End Body---------------------------------------------------------------------------------------->

&nbsp;</td>
	</tr>

</table>
</div>
<!-- ----------------------------------------------- -->
<!-- \\\\\\\\\\\\\\\\\\\\\Begin Footer\\\\\\\\\\\\\\\\\\\\\ -->
<?php include("include/footer.php"); ?>
<!-- \\\\\\\\\\\\\\\\\\\\\End Footer\\\\\\\\\\\\\\\\\\\\\ -->
</body>

</html>